﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;

namespace Kokomo.Environment.Commanding
{
	/// <summary>
	/// Represents a <see cref="CommandViewModel"/> as a menu item.
	/// </summary>
	public class MenuCommandItemViewModel : MenuItemViewModel
	{
		/// <summary>
		/// Initializes a new instance of <see cref="MenuCommandItemViewModel"/>.
		/// </summary>
		/// <param name="commandViewModel">The <see cref="CommandViewModel"/> to display.</param>
		/// <exception cref="ArgumentNullException"><paramref name="commandViewModel"/> is <c>null</c>.</exception>
		public MenuCommandItemViewModel(CommandViewModel commandViewModel)
		{
			if (commandViewModel == null) throw new ArgumentNullException("commandViewModel");
			this.CommandViewModel = commandViewModel;
		}

		/// <summary>
		/// Gets the <see cref="CommandViewModel"/> to display.
		/// </summary>
		public CommandViewModel CommandViewModel { get; private set; }

		/// <summary>
		/// Gets the <see cref="ICommand"/> to execute.
		/// </summary>
		/// <remarks>
		/// This implementation returns the <see cref="Commanding.CommandViewModel.Command"/>
		/// of the underlying <see cref="CommandViewModel"/>
		/// </remarks>
		public override ICommand Command
		{
			get { return this.CommandViewModel.Command; }
		}
		/// <summary>
		/// Gets the argument to pass to the command.
		/// </summary>
		/// <remarks>
		/// This implementation returns the <see cref="Commanding.CommandViewModel.Argument"/>
		/// of the underlying <see cref="CommandViewModel"/>
		/// </remarks>
		public override object CommandArgument
		{
			get { return this.CommandViewModel.Argument; }
		}
		/// <summary>
		/// Gets the text to display.
		/// </summary>
		/// <remarks>
		/// This implementation returns the <see cref="Commanding.CommandViewModel.Text"/>
		/// of the underlying <see cref="CommandViewModel"/>
		/// </remarks>
		public override UiString Text
		{
			get { return this.CommandViewModel.Text; }
		}
		/// <summary>
		/// Gets the icon to display.
		/// </summary>
		/// <remarks>
		/// This implementation returns the <see cref="Commanding.CommandViewModel.IconSource"/>
		/// of the underlying <see cref="CommandViewModel"/>
		/// </remarks>
		public override ImageSource IconSource
		{
			get { return this.CommandViewModel.IconSource; }
		}
	}
}
